﻿using EFCore.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SIService;
using SService;

namespace WMSWeb.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SalesorderController : ControllerBase
    {
        private readonly WmssystemContext myDb;
        private readonly SalesorderS salesorderS;

        public SalesorderController(WmssystemContext myDb, SService.SalesorderS salesorderS)
        {
            this.myDb = myDb;
            this.salesorderS = salesorderS;
        }
        /// <summary>
        /// 4个条件分页查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PO_Salesorder>> Fye(int pageSize, int currentPage, string Number = null, string Status = null, string Cuname = null, DateTime? date = null, DateTime? date1 = null)
        {
            return await salesorderS.Fye(pageSize, currentPage, Number, Status, Cuname, date, date1);
        }
        /// <summary>
        /// 查询总行数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PO_Salesorder>> Qu()
        {
            return await salesorderS.Qu();
        }
        /// <summary>
        /// 销售订单表添加数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> Add(PO_Salesorder pO_Salesorder)
        {
            return await salesorderS.Add(pO_Salesorder);
        }
        /// <summary>
        /// 销售订单审核
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPut]
        public async Task<int> XsShen(PO_Salesorder pO_Salesorder, string to)
        {
            return await salesorderS.XsShen(pO_Salesorder, to);
        }
        /// <summary>
        /// 销售订单批量删除
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpDelete]
        public async Task<int> XsDel(List<int> Ids)
        {
            return await salesorderS.XsDel(Ids);
        }
        /// <summary>
        /// 销售订单修改
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPut]
        public async Task<int> XsUpd(PO_Salesorder pO_Salesorder)
        {
            return await salesorderS.XsUpd(pO_Salesorder);
        }
    }
}
